package com.wmx.entity;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author:wmx 2025-03-12 16:15
 * 1、功能:
 * 2、参数{
 * <p>
 * <p>
 * }
 **/
public class User extends Thread {
    private  String name;
    private  String str;
    ReentrantLock reentrantLock = new ReentrantLock();


    public User(String name, String str) {
        this.name = name;
        this.str = str;
    }

    @Override
    public void run() {
        try {
            reentrantLock.lock();
            System.out.println(toString());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            reentrantLock.unlock();
        }

    }

    @Override
    public synchronized String toString() {
        return this.name+":"+this.str;
    }
}
